/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.TaskCategoryManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class UpdateTaskCategorySort extends AbstractAction
/*    */ {
/*    */   public UpdateTaskCategorySort(AbstractHttpServlet servlet)
/*    */   {
/* 25 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 31 */     String order = Util.getURLParameter(request.getParameter("order"));
/* 32 */     TaskCategoryManager manager = new TaskCategoryManager();
/* 33 */     User user = super.getLoginUser(request);
/* 34 */     int idx = 0;
/* 35 */     if ((order != null) && (order.trim().length() > 0)) {
/* 36 */       String[] ids = order.split("&");
/* 37 */       for (String item : ids)
/* 38 */         if (item.trim().length() != 0)
/*    */         {
/* 41 */           String[] arr = item.split("=");
/* 42 */           if (arr.length == 2)
/*    */           {
/* 45 */             int categoryId = Util.str2Int(arr[1]);
/* 46 */             manager.updateSort(categoryId, idx, user.userId);
/* 47 */             idx++;
/*    */           }
/*    */         }
/*    */     }
/* 50 */     if (idx > 0) {
/* 51 */       CompanyInfo company = super.getCompany(user.companyId);
/*    */       try {
/* 53 */         company.taskCategorys = manager.list(user.companyId);
/*    */       }
/*    */       catch (DBException e) {
/* 56 */         e.printStackTrace();
/*    */       }
/*    */       catch (SQLException e) {
/* 59 */         e.printStackTrace();
/*    */       }
/*    */     }
/* 62 */     response.setContentType("text/html;charset=utf-8");
/* 63 */     PrintWriter out = response.getWriter();
/* 64 */     JSONObject jsonObject = new JSONObject();
/* 65 */     jsonObject.put("error", "0");
/* 66 */     out.println(jsonObject);
/* 67 */     out.flush();
/* 68 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateTaskCategorySort
 * JD-Core Version:    0.6.1
 */